

#import "SinglePicker.h"


@implementation SinglePicker

@synthesize singlePicker;
@synthesize pickerArray;

- (IBAction)pressButton
{
    NSInteger row = [singlePicker selectedRowInComponent:0];
    NSString *choice = [pickerArray objectAtIndex:row];
    
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"title" message:choice delegate:nil cancelButtonTitle:@"cancel" otherButtonTitles:nil];    
    [alert show];
    [alert release];
}

- (void) viewDidLoad
{
    NSArray *x = [[NSArray alloc]initWithObjects:@"tuna", @"fish", @"apples", @"computers", @"ribbons", nil];
    self.pickerArray = x;
    [x release];
    //[super viewDidLoad];
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload 
{
    self.pickerArray=nil;
    self.singlePicker=nil;
    //[super viewDidUnload];
}

- (NSInteger) numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 1;
}

-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    return [pickerArray count];
}


-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    return [pickerArray objectAtIndex:row];
}

- (void)dealloc 
{
    [singlePicker release];
    [pickerArray release];
    [super dealloc];
}

@end
